package cn.wolfcode.controller;


import cn.wolfcode.domain.Result;
import cn.wolfcode.util.OSSUtils;
import com.aliyun.oss.OSSClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
public class Upload {
    @Autowired
    OSSUtils ossUtils;

    @PostMapping("/upload")
    public Result upload(@RequestParam("image") MultipartFile file) throws IOException {
        String upload = ossUtils.upload(file);
        return Result.success(upload);
    }
}
